define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    function get_need_number(){
        $.post("qingdongwms/customer/need/get_need_number",function (data){
            top.window.Backend.api.sidebar({
                'qingdongwms/customer/need/index':[data.data.number, 'red', 'badge'],
                'qingdongwms/customer/need':[data.data.number, 'red', 'badge'],
                'qingdongwms/examine/examine/index':[data.data.examine, 'red', 'badge'], //合同
                'qingdongwms/examine/examine/consume':[data.data.consume, 'red', 'badge'],
                'qingdongwms/examine/examine/receivables':[data.data.receivables, 'red', 'badge'],
                'qingdongwms/examine/examine/achievement':[data.data.achievement, 'red', 'badge'],
                'qingdongwms/examine/examine/work':[data.data.approval, 'red', 'badge'],
                'qingdongwms/examine/examine/parts':[data.data.partin, 'red', 'badge'],
                'qingdongwms/canlendar/canlendar':[data.data.eventOne, 'red', 'badge'],
                'qingdongwms/examine/examine/quote':[data.data.quote, 'red', 'badge'],
                'qingdongwms/examine/examine/invoice':[data.data.invoice, 'red', 'badge'],
                'qingdongwms/examine/examine/delivery':[data.data.delivery, 'red', 'badge'],
                'qingdongwms/examine/examine/instock':[data.data.instock, 'red', 'badge'],
                'qingdongwms/examine/examine/outstock':[data.data.outstock, 'red', 'badge'],
            });
        },'json');
    }
    get_need_number();

    var Controller = {

        index  : function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");


        },
        table: {
            first: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/index?status=0',
                        table: 'contact'
                    }
                });
                // 合同
                var table1 = $("#table");
                table1.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'state', checkbox: true, },
                            {field : 'contract.owner_staff.name', title : __('提交人'), operate: false},

                            {
                                field : 'contract.name', title : '合同名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.contract){
                                        return "<a href='javascript:void(0);' data-id='" + row.contract.id + "' class='show-contract'>" + value + "</a>";
                                    }
                                    return '';
                                },operate:false
                            },
                            {field: 'contract.name', title: '合同名称', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'content', title: __('审批内容')},
                            {field: 'check_time', title: __('审批时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table1, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=contract&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=contract&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                $(document).on('click', '.show-contract', function (data) {
                    var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                    var options = {
                        shadeClose : false,
                        shade      : [0.3, '#393D49'],
                        area       : area,
                        end   : function (value) {
                            //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                           // $(".btn-refresh").trigger("click");
                        }
                    };
                    Fast.api.open("qingdongwms/customer/contract/detail?ids=" + $(this).data('id'), '合同', options);
                });
                // 为表格1绑定事件
                Table.api.bindevent(table1);

            },
            second: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/index?status=1',
                        table: 'contact'
                    }
                });
                // 合同
                var table1 = $("#table1");
                table1.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'state', checkbox: true, },
                            {field : 'contract.owner_staff.name', title : __('提交人'), operate: false},

                            {
                                field : 'contract.name', title : '合同名称', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.contract){
                                        return "<a href='javascript:void(0);' data-id='" + row.contract.id + "' class='show-contract'>" + value + "</a>";
                                    }
                                    return '';
                                },operate:false
                            },
                            {field: 'contract.name', title: '合同名称', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'content', title: __('审批内容')},
                            {field: 'check_time', title: __('审批时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格1绑定事件
                Table.api.bindevent(table1);
            },
            third: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/consume?status=0',
                        table: 'consume'
                    }
                });
                // 费用
                var table2 = $("#table");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'consume.staff.name', title : __('提交人'), operate: false},
                            {field: 'consume.number', title: __('报销单号'), operate:false, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' class='btn-dialog'  data-shade=\"0.3\"\n" +
                                        "data-url=\"qingdongwms/customer/consume/detail?ids=" + row.consume.id+
                                        "\" data-title=\"费用详情\" ' >" + value + "</a>";
                                }},
                            {field: 'consume.submit_date', title: __('消费日期'), operate:false, addclass: 'datetimepicker',data:"data-date-format=\" YYYY-MM-DD\""},

                            {field: 'consume.customer', title: __('关联客户'), operate:false, formatter : function (value, row, index) {
                                    if(row.consume.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.consume.customer.id + "' class='show-customer'>" + row.consume.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},

                            {field: 'consume.money', title: __('消费金额'),operate:false},
                            {field: 'consume.remark', title: __('备注'),operate:false},

                            {field: 'consume.staff.name', title: __('提交人'),operate:false},

                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=consume&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=consume&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                $(document).on('click', '.show-consume', function (data) {
                    var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                    var options = {
                        shadeClose : false,
                        shade      : [0.3, '#393D49'],
                        area       : area,
                        end   : function (value) {
                            //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                            console.log(value);
                            $(".btn-refresh").trigger("click");
                        }
                    };
                    Fast.api.open("qingdongwms/customer/consume/detail?ids=" + $(this).data('id'), '费用详情', options);
                });
                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            four: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/consume?status=1',
                        table: 'consume'
                    }
                });
                // 费用
                var table2 = $("#table1");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'consume.staff.name', title : __('提交人'), operate: false},
                            {field: 'consume.number', title: __('报销单号'), operate:false, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' class='btn-dialog'  data-shade=\"0.3\"\n" +
                                        "data-url=\"qingdongwms/customer/consume/detail?ids=" + row.consume.id+
                                        "\" data-title=\"费用详情\" ' >" + value + "</a>";
                                }},
                            {field: 'consume.submit_date', title: __('消费日期'), operate: false, addclass: 'datetimepicker',data:"data-date-format=\" YYYY-MM-DD\""},

                            {field: 'consume.customer', title: __('关联客户'), operate:false, formatter : function (value, row, index) {
                                    if(row.consume.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.consume.customer.id + "' class='show-customer'>" + row.consume.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},

                            {field: 'consume.money', title: __('消费金额'),operate:false},
                            {field: 'consume.remark', title: __('备注'),operate:false},

                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            five: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/achievement?status=0',
                        table: 'achievement'
                    }
                });
                // 业绩目标
                var table4 = $("#table");
                table4.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar',
                    sortName: 'id',
                    fixedColumns : true,
                    fixedRightNumber  : 1,
                    search: false,
                    columns: [
                        [
                            {field : 'check_staff.name', title : __('提交人'), operate: false},
                            {field: 'achievement.status', title: '业绩目标类型', operate: false, formatter : Table.api.formatter.status, searchList :{1:'获客',2:'拜访',3: '合同金额', 4: '回款金额'}},
                            {field: 'achievement.year', title: '业绩目标年份', operate: false},
                            {field: 'achievement.yeartarget', title: '年目标', operate: false},
                            {field : 'achievement.january', title : __('一月'), operate: false},
                            {field : 'achievement.february', title : __('二月'), operate: false},
                            {field : 'achievement.march', title : __('三月'), operate: false},
                            {field : 'achievement.april', title : __('四月'), operate: false},
                            {field : 'achievement.may', title : __('五月'), operate: false},
                            {field : 'achievement.june', title : __('六月'), operate: false},
                            {field : 'achievement.july', title : __('七月'), operate: false},
                            {field : 'achievement.august', title : __('八月'), operate: false},
                            {field : 'achievement.september', title : __('九月'), operate: false},
                            {field : 'achievement.october', title : __('十月'), operate: false},
                            {field : 'achievement.november', title : __('十一月'), operate: false},
                            {field : 'achievement.december', title : __('十二月'), operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'),width:150, table: table4, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=achievement&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=achievement&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table4);
            },
            six: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/achievement?status=1',
                        table: 'achievement'
                    }
                });
                // 业绩目标
                var table4 = $("#table1");
                table4.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    fixedColumns : true,
                    fixedRightNumber  : 1,
                    search: false,
                    columns: [
                        [
                            {field : 'check_staff.name', title : __('提交人'), operate: false},
                            {field: 'achievement.status', title: '业绩目标类型', operate: false, formatter : Table.api.formatter.status, searchList :{1:'获客',2:'拜访',3: '合同金额', 4: '回款金额'}},
                            {field: 'achievement.year', title: '业绩目标年份', operate: false},
                            {field: 'achievement.yeartarget', title: '年目标', operate: false},
                            {field : 'achievement.january', title : __('一月'), operate: false},
                            {field : 'achievement.february', title : __('二月'), operate: false},
                            {field : 'achievement.march', title : __('三月'), operate: false},
                            {field : 'achievement.april', title : __('四月'), operate: false},
                            {field : 'achievement.may', title : __('五月'), operate: false},
                            {field : 'achievement.june', title : __('六月'), operate: false},
                            {field : 'achievement.july', title : __('七月'), operate: false},
                            {field : 'achievement.august', title : __('八月'), operate: false},
                            {field : 'achievement.september', title : __('九月'), operate: false},
                            {field : 'achievement.october', title : __('十月'), operate: false},
                            {field : 'achievement.november', title : __('十一月'), operate: false},
                            {field : 'achievement.december', title : __('十二月'), operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table4);
            },
            seven: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/receivables?status=0',
                        table: 'receivables'
                    }
                });
                // 回款
                var table3 = $("#table");
                table3.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'receivables.create_staff.name', title : __('提交人'), operate: false},

                            {
                                field : 'receivables.number', title : '回款编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.receivables){
                                        if(!row.receivables.number){
                                            return "<a href='javascript:void(0);' data-id='" + row.relation_id + "' class='show-receivables'>--</a>";
                                        }
                                        return "<a href='javascript:void(0);' data-id='" + row.relation_id + "' class='show-receivables'>" + row.receivables.number + "</a>";
                                    }
                                    return '';
                                },operate:false
                            },
                            {field: 'receivables.return_type', title: '回款方式', operate: false},
                            {field: 'receivables.return_time', title: '回款日期', operate: false},
                            {field: 'receivables.money', title: '回款金额', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table3, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=receivables&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=receivables&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                $(document).on('click', '.show-receivables', function (data) {
                    var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                    var options = {
                        shadeClose : false,
                        shade      : [0.3, '#393D49'],
                        area       : area,
                        end   : function (value) {
                            //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                          //  $(".btn-refresh").trigger("click");
                        }
                    };
                    Fast.api.open("qingdongwms/customer/receivables/detail?ids=" + $(this).data('id'), '回款详情', options);
                });

                // 为表格2绑定事件
                Table.api.bindevent(table3);
            },
            eight: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/receivables?status=1',
                        table: 'receivables'
                    }
                });
                // 回款
                var table3 = $("#table1");
                table3.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'receivables.create_staff.name', title : __('提交人'), operate: false},

                            {
                                field : 'receivables.number', title : '回款编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.receivables){
                                        return "<a href='javascript:void(0);' data-id='" + row.relation_id + "' class='show-receivables'>" + row.receivables.number + "</a>";
                                    }
                                    return '';
                                },operate:false
                            },
                            {field: 'receivables.return_type', title: '回款方式', operate: false},
                            {field: 'receivables.return_time', title: '回款日期', operate: false},
                            {field: 'receivables.money', title: '回款金额', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table3);
            },
            nine: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/work?status=0',
                        table: 'work'
                    }
                });
                // 办公审批
                var table3 = $("#table");
                table3.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,

                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'approval_name', title: __('审批类型'), operate: false},
                            {field : 'approval.create_staff.name', title : __('提交人'), operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table3, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'detail',
                                        text: __('详情'),
                                        classname: 'records btn-dialog',
                                        url: function (row) {
                                            return 'qingdongwms/work/approval/detail?ids=' + row.approval.id;
                                        },
                                        extend: "data-area='[\"80%\", \"80%\"]'",
                                        callback: function (data) {
                                            Layer.alert("接收到回传数据：" + JSON.stringify(data), {title: "回传数据"});
                                            $(".btn-refresh").trigger("click");
                                        }
                                    },
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=approval&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=approval&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                $(document).on('click', '.show-receivables', function (data) {
                    var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                    var options = {
                        shadeClose : false,
                        shade      : [0.3, '#393D49'],
                        area       : area,
                        end   : function (value) {
                            //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                          //  $(".btn-refresh").trigger("click");
                        }
                    };
                    Fast.api.open("qingdongwms/customer/receivables/detail?ids=" + $(this).data('id'), '回款详情', options);
                });

                // 为表格2绑定事件
                Table.api.bindevent(table3);
            },
            ten: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/work?status=1',
                        table: 'work'
                    }
                });
                // 办公审批
                var table3 = $("#table1");
                table3.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,

                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'approval_name', title: __('审批类型'), operate: false},
                            {field : 'approval.create_staff.name', title : __('提交人'), operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table3, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'detail',
                                        text: __('详情'),
                                        classname: 'records btn-dialog',
                                        url: function (row) {
                                            return 'qingdongwms/work/approval/detail?ids=' + row.approval.id;
                                        },
                                        extend: "data-area='[\"80%\", \"80%\"]'",
                                        callback: function (data) {
                                            Layer.alert("接收到回传数据：" + JSON.stringify(data), {title: "回传数据"});
                                            $(".btn-refresh").trigger("click");
                                        }
                                    },
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=approval&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=approval&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table3);
            },
            quotecheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/quote?status=0',
                        table: 'work'
                    }
                });
                // 办公审批
                var table = $("#table");
                table.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,

                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'state', checkbox: true, },
                            {field : 'quote.owner_staff.name', title : __('提交人'), operate:false,searchList:$.getJSON("qingdongwms/customer/customer/stafflist")},
                            {
                                field : 'quote.number', title : '报价单编号', fixedColumns : true, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' class='btn-dialog' " +
                                        "data-url='qingdongwms/customer/quote/detail/ids/"+row.quote.id+"' data-shade='0.3' data-title='报价单详情' >" + value + "</a>";
                                },operate:false
                            },
                            {
                                field : 'quote.customer.name', title : '客户信息', fixedColumns : true, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' class='btn-dialog' " +
                                        "data-url='qingdongwms/customer/customer/detail/ids/"+row.quote.customer.id+"' data-shade='0.3' data-title='客户详情' >" + row.quote.customer.name  + "</a>";
                                },operate:false
                            },
                            {field: 'quote.quote_amount', title: '报价金额', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate:'=', formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-ajax',
                                        confirm: '确认要审核通过当前报价单?',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=quote&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-ajax',
                                        confirm: '确认要拒绝通过当前报价单?',
                                        refresh:true,
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=quote&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table);
            },
            quotesuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/quote?status=1',
                        table: 'work'
                    }
                });
                // 办公审批
                var table = $("#table1");
                table.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,

                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field: 'state', checkbox: true, },
                            {field : 'quote.owner_staff.name', title : __('提交人'), operate:false,searchList:$.getJSON("qingdongwms/customer/customer/stafflist")},

                            {
                                field : 'quote.number', title : '报价单编号', fixedColumns : true, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' class='btn-dialog' " +
                                        "data-url='qingdongwms/customer/quote/detail/ids/"+row.quote.id+"' data-shade='0.3' data-title='报价单详情' >" + value + "</a>";
                                },operate:false
                            },
                            {
                                field : 'quote.customer.name', title : '客户信息', fixedColumns : true, formatter : function (value, row, index) {

                                    return "<a href='javascript:void(0);' class='btn-dialog' " +
                                        "data-url='qingdongwms/customer/customer/detail/ids/"+row.quote.customer.id+"' data-shade='0.3' data-title='客户详情' >" + row.quote.customer.name  + "</a>";
                                },operate:false
                            },
                            {field: 'quote.quote_amount', title: '报价金额', operate: false},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate:'=', formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });
                // 为表格2绑定事件
                Table.api.bindevent(table);
            },
            invoicecheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/invoice?status=0',
                        table: 'invoice'
                    }
                });
                // 费用
                var table2 = $("#table");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'invoice.create_staff.name', title : __('提交人'), operate: false},
                            {field: 'invoice.number', title: __('发票编号'), operate:false, formatter : function (value, row, index) {
                                    if(!row.invoice){
                                        return '';
                                    }
                                    return "<a href='javascript:void(0);' class='btn-dialog' data-area=[\"95%\",\"95%\"] data-shade=\"0.3\"\n" +
                                        "data-url=\"qingdongwms/finance/invoice/detail?ids=" + row.invoice.id+
                                        "\" data-title=\"发票详情\" ' >" + value + "</a>";
                                }},
                            {field: 'invoice.time', title: __('开票日期'), operate:false},

                            {field: 'invoice.customer', title: __('客户名称'), operate:false, formatter : function (value, row, index) {
                                    if(row.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.customer.id + "' class='show-customer'>" + row.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},
                            {field: 'invoice.contract', title: __('合同编号'), operate:false, formatter : function (value, row, index) {
                                    if(row.contract){
                                        return "<a href='javascript:void(0);' data-id='" + row.contract.id + "' class='show-contract'>" + row.contract.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},
                            {field: 'invoice.money', title: __('消费金额'),operate:false},
                            {field: 'invoice.remark', title: __('备注'),operate:false},

                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=invoice&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=invoice&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            console.log(data, ret);
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            invoicesuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/invoice?status=1',
                        table: 'invoice'
                    }
                });
                // 费用
                var table2 = $("#table1");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {field : 'invoice.create_staff.name', title : __('提交人'), operate: false},
                            {field: 'invoice.number', title: __('发票编号'), operate:false, formatter : function (value, row, index) {
                                    if(!row.invoice){
                                        return '';
                                    }
                                    return "<a href='javascript:void(0);' class='btn-dialog' data-area=[\"95%\",\"95%\"] data-shade=\"0.3\"\n" +
                                        "data-url=\"qingdongwms/finance/invoice/detail?ids=" + row.invoice.id+
                                        "\" data-title=\"发票详情\" ' >" + value + "</a>";
                                }},
                            {field: 'invoice.time', title: __('开票日期'), operate:false},

                            {field: 'invoice.customer', title: __('关联客户'), operate:false, formatter : function (value, row, index) {
                                    if(row.invoice.customer){
                                        return "<a href='javascript:void(0);' data-id='" + row.invoice.customer_id + "' class='show-customer'>" + row.consume.customer.name + "</a>";
                                    }else{
                                        return '';
                                    }
                                }},

                            {field: 'invoice.money', title: __('消费金额'),operate:false},
                            {field: 'invoice.remark', title: __('备注'),operate:false},

                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field: 'status', title: __('审批状态'), operate: false, formatter: Table.api.formatter.status,  searchList: {0: __('待审批'), 1: __('审批通过'), 2: __('审批拒绝'), 3: __('撤销')}},
                            {field: 'createtime', title: __('创建时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            deliverycheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/delivery?status=0',
                        table: 'delivery'
                    }
                });
                // 费用
                var table2 = $("#table");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'delivery.num', title : '发货单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.delivery){
                                        return "<a href='javascript:void(0);' class='btn-dialog'" +
                                            "data-url='qingdongwms/customer/delivery/detail/ids/"+row.delivery.id+"' data-area=[\"95%\",\"95%\"] data-title='发货单详情' >" + value + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:'like'
                            },
                            {field : 'delivery.customer', title : '客户名称', formatter : function (value, row, index) {
                                    if(row.delivery){
                                        return "<a href='javascript:void(0);' class='btn-dialog'" +
                                            "data-url='qingdongwms/customer/customer/detail/ids/"+row.delivery.customer_id+"' data-area=[\"95%\",\"95%\"] data-title='客户详情'>" + row.delivery.customer.name + "</a>";
                                    }
                                    return '';
                                },operate:false},
                            {field : 'delivery.order_date', title : '送货日期',operate: 'RANGE', addclass: 'datetimerange'},
                            {field : 'delivery.warehouse.name', title : '发货仓库',operate:false},
                            {field : 'delivery.money', title : '发货单金额',operate:false},
                            {field : 'delivery.check_status', title : '发货单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'delivery.staff.name', title : __('提交人'), operate: false},
                            {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=delivery&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=delivery&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            deliverysuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/delivery?status=1',
                        table: 'delivery'
                    }
                });
                // 费用
                var table2 = $("#table1");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'delivery.num', title : '发货单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(row.delivery){
                                        return "<a href='javascript:void(0);' class='btn-dialog'" +
                                            "data-url='qingdongwms/customer/delivery/detail/ids/"+row.delivery.id+"' data-area=[\"95%\",\"95%\"] data-title='发货单详情' >" + value + "</a>";
                                    }else{
                                        return '';
                                    }

                                },operate:'like'
                            },
                            {field : 'delivery.customer', title : '客户名称', formatter : function (value, row, index) {
                                    if(row.delivery){
                                        return "<a href='javascript:void(0);' class='btn-dialog' " +
                                            "data-url='qingdongwms/customer/customer/detail/ids/"+row.delivery.customer_id+"' data-area=[\"95%\",\"95%\"] data-title='客户详情'>" + row.delivery.customer.name + "</a>";
                                    }
                                    return '';
                                },operate:false},
                            {field : 'delivery.order_date', title : '送货日期',operate: 'RANGE', addclass: 'datetimerange'},
                            {field : 'delivery.warehouse.name', title : '发货仓库',operate:false},
                            {field : 'delivery.money', title : '发货单金额',operate:false},
                            {field : 'delivery.check_status', title : '发货单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'delivery.staff.name', title : __('提交人'), operate: false},
                            {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            instockcheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/instock?status=0',
                        table: 'instock'
                    }
                });
                // 费用
                var table2 = $("#table");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'instock.num', title : '入库单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(value =='' || !row.instock){
                                        value = '无';
                                    }
                                    return "<a href='javascript:void(0);'  class='btn-dialog' " +
                                        "data-url='qingdongwms/stock/instock/detail/ids/"+row.instock.id+"' data-area=[\"95%\",\"95%\"] data-title='入库单详情'>" + value + "</a>";
                                },operate:'like'
                            },

                            {field : 'instock.money', title : '入库单金额',operate:false},

                            {field : 'instock.remarks', title : '备注',operate:false},
                            {field : 'instock.check_status', title : '入库单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'instock.staff.name', title : __('提交人'), operate: false},
                            {field: 'instock.createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=instock&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=instock&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        success:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            instocksuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/instock?status=1',
                        table: 'instock'
                    }
                });
                // 费用
                var table2 = $("#table1");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'instock.num', title : '入库单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(value =='' || !row.instock){
                                        value = '无';
                                    }
                                    return "<a href='javascript:void(0);'  class='btn-dialog' " +
                                        "data-url='qingdongwms/stock/instock/detail/ids/"+row.instock.id+"' data-area=[\"95%\",\"95%\"] data-title='入库单详情'>" + value + "</a>";
                                },operate:'like'
                            },

                            {field : 'instock.money', title : '入库单金额',operate:false},

                            {field : 'instock.remarks', title : '备注',operate:false},
                            {field : 'instock.check_status', title : '入库单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'instock.staff.name', title : __('提交人'), operate: false},
                            {field: 'instock.createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
            outstockcheck: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/outstock?status=0',
                        table: 'outstock'
                    }
                });
                // 费用
                var table2 = $("#table");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'outstock.num', title : '出库单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(value =='' || !row.outstock){
                                        value = '无';
                                    }
                                    return "<a href='javascript:void(0);'  class='btn-dialog' " +
                                        "data-url='qingdongwms/stock/outstock/detail/ids/"+row.outstock.id+"' data-area=[\"95%\",\"95%\"] data-title='出库单详情'>" + value + "</a>";
                                },operate:'like'
                            },

                            {field : 'outstock.money', title : '出库单金额',operate:false},

                            {field : 'outstock.remarks', title : '备注',operate:false},
                            {field : 'outstock.check_status', title : '出库单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'outstock.staff.name', title : __('提交人'), operate: false},
                            {field: 'outstock.createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                            {field: 'operate', title: __('Operate'), table: table2, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
                                buttons: [
                                    {
                                        name: 'success',
                                        text: __('通过'),
                                        title: __('通过'),
                                        classname: 'records btn-dialog',
                                        area:'',
                                        refresh:true,
                                        icon: 'fa fa-check',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=outstock&relation_id={relation_id}&status=1&noreload=1',
                                        visible: function (row) {
                                            //返回true时按钮显示,返回false隐藏
                                            return true;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                    {
                                        name: 'error',
                                        text: __('拒绝'),
                                        title: __('拒绝'),
                                        classname: 'records btn-dialog',
                                        extend: ' data-area=\'\'',
                                        refresh:true,
                                        icon: 'fa fa-close',
                                        url: 'qingdongwms/examine/examine_record/examine?relation_type=outstock&relation_id={relation_id}&status=2&noreload=1',
                                        error: function (data, ret) {
                                            Layer.alert(ret.msg);
                                            return false;
                                        },
                                        callback:function(data){
                                            get_need_number();
                                            $(".btn-refresh").trigger("click");
                                        },
                                    },
                                ]
                            }

                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });


                // 为表格2绑定事件
                Table.api.bindevent(table2);

            },
            outstocksuccess: function () {
                // 初始化表格参数配置
                Table.api.init({
                    extend: {
                        index_url: 'qingdongwms/examine/examine/outstock?status=1',
                        table: 'outstock'
                    }
                });
                // 费用
                var table2 = $("#table1");
                table2.bootstrapTable({
                    url: $.fn.bootstrapTable.defaults.extend.index_url,
                    toolbar: '#toolbar1',
                    sortName: 'id',
                    search: false,
                    columns: [
                        [
                            {
                                field : 'outstock.num', title : '出库单编号', fixedColumns : true, formatter : function (value, row, index) {
                                    if(value =='' || !row.outstock){
                                        value = '无';
                                    }
                                    return "<a href='javascript:void(0);'  class='btn-dialog' " +
                                        "data-url='qingdongwms/stock/outstock/detail/ids/"+row.outstock.id+"' data-area=[\"95%\",\"95%\"] data-title='出库单详情'>" + value + "</a>";
                                },operate:'like'
                            },

                            {field : 'outstock.money', title : '出库单金额',operate:false},

                            {field : 'outstock.remarks', title : '备注',operate:false},
                            {field : 'outstock.check_status', title : '出库单状态',formatter:Table.api.formatter.status, searchList: {0:'待审核', 1: '审核中',2:'审核通过',3:"审核未通过",4:"已撤销"}},
                            {field: 'check_staff.name', title: __('审批人'), operate: false},
                            {field : 'outstock.staff.name', title : __('提交人'), operate: false},
                            {field: 'outstock.createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        ]
                    ],
                    //启用普通表单搜索
                    commonSearch: true,
                    searchFormVisible: true,
                });

                // 为表格2绑定事件
                Table.api.bindevent(table2);
            },
        },
        consume  : function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
            $(document).on('click', '.show-customer', function (data) {
                var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                var options = {
                    shadeClose : false,
                    shade      : [0.3, '#393D49'],
                    area       : area,
                    end   : function (value) {
                        //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                        console.log(value);
                        $(".btn-refresh").trigger("click");
                    }
                };
                Fast.api.open("qingdongwms/customer/customer/detail?ids=" + $(this).data('id'), '客户详情', options);
            });

        },
        receivables  : function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");


        },

        achievement  : function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");


        },

        quote: function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");

            $(document).on('click', '.show-quote', function (data) {
                var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                var options = {
                    shadeClose : false,
                    shade      : [0.3, '#393D49'],
                    area       : area,
                    end   : function (value) {
                        //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                        console.log(value);
                        $(".btn-refresh").trigger("click");
                    }
                };
                Fast.api.open("qingdongwms/customer/quote/detail?ids=" + $(this).data('id'), '报价单详情', options);
            })
                .on('click', '.show-customer', function (data) {
                var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
                var options = {
                    shadeClose : false,
                    shade      : [0.3, '#393D49'],
                    area       : area,
                    end   : function (value) {
                        //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                        console.log(value);
                        $(".btn-refresh").trigger("click");
                    }
                };
                Fast.api.open("qingdongwms/customer/customer/detail?ids=" + $(this).data('id'), '客户详情', options);
            });
        },

        work  : function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");


        },
        invoice  : function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
            $(document).on('click', '.show-customer', function (data) {
                var area = ['95%', '95%'];
                var options = {
                    shadeClose : false,
                    shade      : [0.3, '#393D49'],
                    area       : area,
                    callback   : function (value) {
                        //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                        console.log(value);
                    }
                };
                Fast.api.open($.fn.bootstrapTable.defaults.extend.customer_url + "?ids=" + $(this).data('id'), '客户详情', options);
            });
            $(document).on('click', '.show-contract', function (data) {
                var area = ['95%', '95%'];
                var options = {
                    shadeClose : false,
                    shade      : [0.3, '#393D49'],
                    area       : area,
                    callback   : function (value) {
                        //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
                        console.log(value);
                    }
                };
                Fast.api.open($.fn.bootstrapTable.defaults.extend.contract_url + "?ids=" + $(this).data('id'), '客户详情', options);
            });

        },
        //发货单
        delivery: function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
        },
        //入库单
        instock: function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
        },
        //出库单
        outstock: function () {
            // 初始化表格参数配置
            Table.api.init();

            //绑定事件
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var panel = $($(this).attr("href"));
                if (panel.length > 0) {
                    Controller.table[panel.attr("id")].call(this);
                    $(this).on('click', function (e) {
                        $($(this).attr("href")).find(".btn-refresh").trigger("click");
                    });
                }
                //移除绑定的事件
                $(this).unbind('shown.bs.tab');
            });

            //必须默认触发shown.bs.tab事件
            $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");

        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
        }
    };
    return Controller;
});